#include "User.h"
#include "Constants.h"
#include "QDebug"

User::User(QString userAddress, QString userName, QString userPassword, int userPort)
    : currentPiece(" ")
{
    initialized = false;
    this->userAddress = userAddress;
    this->userName = userName;
    this->userPassword = userPassword;
    this->userPort = userPort;
    aliveTimer = 0;
    qDebug() << "Succuesfully added user : " << qPrintable(userName);
    qDebug()   << "User name: " << qPrintable(userName);
    qDebug()    << "User password: "<< qPrintable(userPassword);
    qDebug()    << "User Address: "<< qPrintable(userAddress);
    qDebug()    << "User port: "<< userPort;
    /*
    this->transmitSocket = new UdpTransmitSocket(
            IpEndpointName(
                    qPrintable(this->userAddress),
                    this->userPort
                    )
            );
            */
    initialized = true;
}
User::~User() {
    qDebug() << "Disconnecting User " << qPrintable(userName);
    //delete this->transmitSocket;
}
/*
void User::sendUser(osc::OutboundPacketStream p) {
    this->transmitSocket->Send(p.Data(),p.Size());
}
*/
IpEndpointName User::getIp() {
    return IpEndpointName(
            qPrintable(this->userAddress),
            this->userPort
            );
}

QString User::getUserName() {
    return userName;
}
QString User::getUserPassword() {
    return userPassword;
}
void User::setAliveTimer(int time) {
    this->aliveTimer = time;
}
void User::increaseAliveTimer(int time) {
    aliveTimer = aliveTimer + time;
}
int User::getAliveTimer() {
    return this->aliveTimer;
}
bool User::isInitialized() {

}

void User::changePiece(QString piece)
{
    this->currentPiece = piece;
}

QString User::getPiece()
{
    return currentPiece;
}


